package com.linkin.homepage.base.net;


import java.io.Serializable;


public interface IResponseData extends Serializable {
    int SUCCESS_ERROR_NUM        = 0;
    int SUCCESS_RESPONSE        = 1000;
    int ERROR_TIME_OUT          = -9999;
    int ERROR_NET_ERROR         = -9998;
    int ERROR_PARSE_JSON        = -9997;
    int ERROR_TOKEN             = -4;

    void setErrorCode(int errorCode);
    int getErrorCode();
    int getSuccessResponse();
    void setMsg(String msg);
    boolean hasData();

    default boolean check() {
        return checkErrorCode() && checkSuccess() && hasData();
    }

    default boolean checkErrorCode() {
        return getErrorCode() == SUCCESS_ERROR_NUM;
    }

    default boolean checkSuccess(){
        return getSuccessResponse() == SUCCESS_RESPONSE;
    }

    default boolean tokenError() {
        return getErrorCode() == ERROR_TOKEN;
    }

    default boolean timeOut() {
        return getErrorCode() == ERROR_TIME_OUT;
    }

    default boolean netError() {
        return getErrorCode() == ERROR_NET_ERROR;
    }

    default boolean parseJsonError() {
        return getErrorCode() == ERROR_PARSE_JSON;
    }
}
